#include "Progress.h"


char state[] = "|/-\\";
void process_v1(){
    int rate = 0;
    char bar[SIZE];
    int len =strlen(state);
    memset(bar,'\0',sizeof(bar));
    while(rate <= 100) {
        printf("[%-100s][%d%%][%c]\r",bar,rate,state[rate%len]);
        fflush(stdout);
        usleep(PAUSE_TIME);
        bar[rate++] = symbol;
    }
    printf("\n");
}
void process_v2(int rate){
   static char bar[SIZE] = {0};
   static int cnt = 0;
   int len = strlen(state);
    if(rate >=0 && rate <=100){    
        printf("[%-100s][%d%%][%c]\r",bar,rate,state[cnt%len]);
        fflush(stdout);
        bar[rate] = '#';
        cnt++;
    }
   // if(rate == 100) memset(bar, '\0', sizeof(bar));
}

void process_v3(double rate){
   static char bar[SIZE] = {0};
   static int cnt = 0;
   int len = strlen(state);
    if(rate >=0 && rate <=100){    
        printf("[\033[31m%-100s\033[0m][%0.1lf%%][%c]\r",bar,rate,state[cnt%len]);
        fflush(stdout);
        bar[(int)rate] = '#';
        cnt++;
    }
}



